
package com.putao.tinytime.activities.menu;

import android.app.Notification;
import android.app.NotificationManager;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.RadioGroup;

import com.putao.tinytime.R;
import com.putao.tinytime.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class MenuTabHostActivity extends BaseActivity
{
    //    public static boolean isCheckVer;
    public RadioGroup rgs;
    public List<Fragment> fragments = new ArrayList<Fragment>();

    @Override
    public int doGetContentViewId()
    {
        return R.layout.activity_menu_tab_host;
    }

    @Override
    public void doInitSubViews(View view)
    {
        fragments.add(new TinyTimeSampleListFragment());
        fragments.add(new MenuFragment2());
        //        fragments.add(new MineFragment());
        rgs = (RadioGroup) findViewById(R.id.tabs_rg);
        FragmentTabAdapter tabAdapter = new FragmentTabAdapter(this, fragments, R.id.tab_content, rgs);
        tabAdapter.setOnRgsExtraCheckedChangedListener(new FragmentTabAdapter.OnRgsExtraCheckedChangedListener()
        {
            @Override
            public void OnRgsExtraCheckedChanged(RadioGroup radioGroup , int checkedId , int index)
            {
                switch (index)
                {
                    case 0:
                        break;
                    case 1:
                        break;
                    case 2:
                        break;
                }
            }
        });
        //        if (!EventBus.getEventBus().isRegistered(this))
        //        {
        //            EventBus.getEventBus().register(this);
        //        }
    }

    @Override
    public void doInitData()
    {
        //        if (!Utils.hasBind(getApplicationContext()))
        //        {
        //            // ??AndroidManifest.xml 104?? api_key ????????? api_key ???? ??
        //            // ATTENTION?You need to modify the value of api_key to your own at row 104 in AndroidManifest.xml to use this Demo !!
        //            PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Constants.BAIDU_PUSH_APIKEY);
        //            // Push: ????????????????????????????
        //            //            PushManager.enableLbs(getApplicationContext());
        //        }
        //        if (PushManager.isPushEnabled(getApplicationContext()))
        //        {
        //            PushManager.resumeWork(getApplicationContext());
        //        }
        //        checkIsFirstOpenApplication();
    }

    @Override
    protected void onResumeFragments()
    {
        super.onResumeFragments();
        //        if (isCheckVer)
        //        {
        //            isCheckVer = false;
        //            String nowTime = B5MPreferenceHelper.readStringValue(TabHostActivity.this, B5MPreferenceHelper.NowTime);
        //            if (B5MStringHelper.isEmpty(nowTime))
        //            {
        //                onCheckUpdate();
        //                return;
        //            }
        //            long date = CalendarUtil.getTwoDay(CalendarUtil.getNowTime("yyyy-MM-dd"), nowTime);
        //            if (date > 0)
        //            {
        //                onCheckUpdate();
        //            }
        //        }
    }

    //    @Override
    //    public boolean onKeyDown(int keyCode, KeyEvent event)
    //    {
    //        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
    //        {
    //            if (rgs.getCheckedRadioButtonId() != rgs.getChildAt(0).getId())
    //            {
    //                rgs.check(rgs.getChildAt(0).getId());
    //                return true;
    //            }
    //            if ((System.currentTimeMillis() - exitTime) > 2000)
    //            {
    //                B5MToaster.showShort(TabHostActivity.this, "????????", 0);
    //                exitTime = System.currentTimeMillis();
    //            }
    //            else
    //            {
    //                YARAppManager.getInstance().AppExit(getApplicationContext());
    //            }
    //            return true;
    //        }
    //        return super.onKeyDown(keyCode, event);
    //    }
    //
    //    private void doHomeKey()
    //    {
    //        Intent intent = new Intent(Intent.ACTION_MAIN);
    //        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    //        intent.addCategory(Intent.CATEGORY_HOME);
    //        startActivity(intent);
    //    }
    @Override
    public void onDestroy()
    {
        //        if (mNotificationManager != null)
        //        {
        //            mNotificationManager.cancel(NOTIFICATION_ID);
        //        }
        //        cancel();
        //        EventBus.getEventBus().unregister(this);
        super.onDestroy();
    }
    private static final int NOTIFICATION_ID = 0x12;
    private Notification mNotification = null;
    private NotificationManager mNotificationManager = null;
    private Handler mHandler;
}